-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Core] Modern visitor creation #5126
base: master
Are you sure you want to change the base?
Conversation
The unit tests fail because lambdas on |
…n the non-interaction component
[ci-build][with-all-tests] |
BottomUpVisitor() = default; | ||
}; | ||
|
||
inline TopDownVisitor topDownVisitor {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using the same name with only no capital letter at the beginning is misleading. Given the fact that this is kind of equivalent to a static object, why not add a suffix ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no guidelines in SOFA relative to the naming of global variables (I already saw a convention with a g_
prefix). But I agree with you the names of the type and the variable are too similar. The STL has the same design for execution policy, and the variable names are truncated to differentiate with the type names. But here, I don't like it so much. Let's discuss that in the dev meeting.
Keep in mind that this is a detail of one of the implementation of the visitors. We still need to decide which one of both implementations we keep. That's the main question of this PR.
@sofa-framework/reviewers your opinion is needed. While working on the visitor definition, Alex proposes two alternative methods: the creation of classical SOFA visitors or a new implementation of the original visitor design pattern. It is a known pattern, slightly more verbous but the implementation follows modern C++ format (accept combined with lambda). A second version of these modern visitors is presented (see MechanicalOperations.cpp) with a function e.g. We thought @JeremieA you could have an interesting point of view about this. |
This PR makes several suggestions, and should not be considered as is for a merge. A choice on the implementations must be made.
void accept(TopDownVisitor& visitor)
) https://refactoring.guru/design-patterns/visitor/cpp/example. It is a new implementation of the visitors, independent from the old visitors.makeMechanicalVisitor
.MechanicalOperations
uses a mix of old fashion visitors, and new visitors. The file must be reviewed as an example of usage.Example of the new visitors:
Example of the old visitors:
Pros:
Cons:
TODO with the new visitors:
BaseForceField
andBaseInteractionForceField
BaseMechanicalVisitor
and old visitorsThe question is: which implementation of the visitors do we keep?
Future work: Implement this kind of "visitor" for the mapping graph
By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).
Reviewers will merge this pull-request only if